package org.lys.service.impl;

import java.util.List;

import org.lys.dao.UserDao;
import org.lys.dao.impl.jdbc.UserDaoImpl;
import org.lys.model.User;
import org.lys.service.UserService;
import org.lys.util.Pagination;

public class UserServiceImpl implements UserService {

	private UserDao userDao = new UserDaoImpl();
	
	@Override
	public int add(User user) {
		return userDao.add(user);
	}

	@Override
	public void delete(User user) {
		userDao.delete(user);
	}

	@Override
	public void update(User user) {
		userDao.update(user);
	}

	@Override
	public List<User> query(User user) {
		return userDao.query(user);
	}

	@Override
	public User get(int id) {
		return userDao.get(id);
	}

	@Override
	public Pagination queryPage(User user, Pagination pagination) {
		int count  = userDao.count(user);
		
		pagination.setRowCount(count);
		List<User> userList = userDao.queryPage(user,pagination);
		
		pagination.setData(userList);
		
		return pagination;
	}

}
